package com.yenlien.traceyun.plant.controller;

import com.yenlien.traceyun.plant.entity.*;
import com.yenlien.traceyun.plant.service.YenlienService;
import com.yenlien.traceyun.webase.controller.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;


@RestController
@RequestMapping("/yenlien")
@Api(tags = "原链官网")
public class YenlienController extends BaseController {

    @Autowired
    private YenlienService yenlienService;



    @PostMapping(value = "/saveBanner")
    @ApiOperation(value = "保存/修改Banner", notes = "img为图片上传后的名字(图片先上传)。有Id则代表修改，没有则是添加")
    public Object save(@RequestBody YenlienBanner yenlienBanner)  {
        return success(yenlienService.saveBanner(yenlienBanner));
    }

    @PostMapping(value = "/saveProjectExample")
    @ApiOperation(value = "保存/修改项目案例", notes = "img为图片上传后的名字(图片先上传)。有Id则代表修改，没有则是添加")
    public Object saveProjectExample(@RequestBody YenlienProjectExample yenlienProjectExample)  {
        return success(yenlienService.saveProjectExample(yenlienProjectExample));
    }

    @PostMapping(value = "/saveProduct")
    @ApiOperation(value = "保存/修改产品服务", notes = "img为图片上传后的名字(图片先上传)。有Id则代表修改，没有则是添加")
    public Object saveProduct(@RequestBody YenlienProduct yenlienProduct)  {
        return success(yenlienService.saveProduct(yenlienProduct));
    }

    @PostMapping(value = "/saveSolution")
    @ApiOperation(value = "保存/修改解决方案", notes = "")
    public Object saveSolution(@RequestBody YenlienSolution yenlienSolution)  {
        return success(yenlienService.saveSolution(yenlienSolution));
    }

    @PostMapping(value = "/saveNews")
    @ApiOperation(value = "保存/修改新闻资讯", notes = "")
    public Object saveNews(@RequestBody YenlienNews yenlienNews)  {
        return success(yenlienService.saveNews(yenlienNews));
    }

    @PostMapping(value = "/saveInfo")
    @ApiOperation(value = "保存/修改关于我们", notes = "")
    public Object saveInfo(@RequestBody Yenlien yenlien)  {
        return success(yenlienService.saveInfo(yenlien));
    }







    @PostMapping(value = "/findBannerPage")
    @ApiOperation(value = "分页查询Banner", notes = "可选参数: type")
    public Object findBannerPage(@RequestBody YenlienBanner yenlienBanner)  {
        return success(yenlienService.findBanner(yenlienBanner));
    }
    @PostMapping(value = "/findBannerList")
    @ApiOperation(value = "查询Banner", notes = "可选参数: type")
    public Object findBannerList(@RequestBody YenlienBanner yenlienBanner)  {
        return success(yenlienService.findBannerList(yenlienBanner));
    }
    @GetMapping(value = "/findBannerById")
    @ApiOperation(value = "根据ID查询Banner详情", notes = "参数：id")
    public Object findBannerById(String id)  {
        return success(yenlienService.findBannerById(id));
    }
    @GetMapping(value = "/delBannerById")
    @ApiOperation(value = "根据ID删除Banner", notes = "参数：id")
    public Object delBannerById(String id)  {
        yenlienService.delBannerById(id);
        return success("success");
    }


    @PostMapping(value = "/findProjectExamplePage")
    @ApiOperation(value = "分页查询项目案例", notes = "可选参数: name, state")
    public Object findProjectExamplePage(@RequestBody YenlienProjectExample yenlienProjectExample)  {
        return success(yenlienService.findProjectExamplePage(yenlienProjectExample));
    }
    @PostMapping(value = "/findProjectExampleList")
    @ApiOperation(value = "查询项目案例", notes = "可选参数: name, state")
    public Object findProjectExampleList(@RequestBody YenlienProjectExample yenlienProjectExample)  {
        return success(yenlienService.findProjectExampleList(yenlienProjectExample));
    }
    @GetMapping(value = "/findProjectExampleById")
    @ApiOperation(value = "根据ID查询项目案例详情", notes = "参数：id")
    public Object findProjectExampleById(String id)  {
        return success(yenlienService.findProjectExampleById(id));
    }
    @GetMapping(value = "/delProjectExampleById")
    @ApiOperation(value = "根据ID删除项目案例", notes = "参数：id")
    public Object delProjectExampleById(String id)  {
        yenlienService.delProjectExampleById(id);
        return success("success");
    }


    @PostMapping(value = "/findProductPage")
    @ApiOperation(value = "分页查询产品服务", notes = "可选参数: name, homeShow, state")
    public Object findProductPage(@RequestBody YenlienProduct yenlienProduct)  {
        return success(yenlienService.findProductPage(yenlienProduct));
    }
    @PostMapping(value = "/findProductList")
    @ApiOperation(value = "查询产品服务", notes = "可选参数: name, homeShow, state")
    public Object findProductList(@RequestBody YenlienProduct yenlienProduct)  {
        return success(yenlienService.findProductList(yenlienProduct));
    }
    @GetMapping(value = "/findProductById")
    @ApiOperation(value = "根据ID查询产品服务详情", notes = "参数：id")
    public Object findProductById(String id)  {
        return success(yenlienService.findProductById(id));
    }
    @GetMapping(value = "/delProductById")
    @ApiOperation(value = "根据ID删除产品服务", notes = "参数：id")
    public Object delProductById(String id)  {
        yenlienService.delProductById(id);
        return success("success");
    }


    @PostMapping(value = "/findSolutionPage")
    @ApiOperation(value = "分页查询解决方案", notes = "可选参数: name, planName")
    public Object findSolutionPage(@RequestBody YenlienSolution yenlienSolution)  {
        return success(yenlienService.findSolutionPage(yenlienSolution));
    }
    @PostMapping(value = "/findSolutionList")
    @ApiOperation(value = "查询解决方案", notes = "可选参数: name, planName")
    public Object findSolutionList(@RequestBody YenlienSolution yenlienSolution)  {
        return success(yenlienService.findSolutionList(yenlienSolution));
    }
    @GetMapping(value = "/findSolutionById")
    @ApiOperation(value = "根据ID查询解决方案详情", notes = "参数：id")
    public Object findSolutionById(String id)  {
        return success(yenlienService.findSolutionById(id));
    }
    @GetMapping(value = "/delSolutionById")
    @ApiOperation(value = "根据ID删除解决方案", notes = "参数：id")
    public Object delSolutionById(String id)  {
        yenlienService.delSolutionById(id);
        return success("success");
    }


    @PostMapping(value = "/findNewsPage")
    @ApiOperation(value = "分页查询新闻资讯", notes = "可选参数: name, homeShow, publisher, state(1=已发布 2=待发布), type=文章类型")
    public Object findNewsPage(@RequestBody YenlienNews yenlienNews)  {
        return success(yenlienService.findNewsPage(yenlienNews));
    }
    @PostMapping(value = "/findNewsList")
    @ApiOperation(value = "查询新闻资讯", notes = "可选参数: name, homeShow, publisher")
    public Object findNewsList(@RequestBody YenlienNews yenlienNews)  {
        return success(yenlienService.findNewsList(yenlienNews));
    }
    @GetMapping(value = "/findNewsById")
    @ApiOperation(value = "根据ID查询新闻资讯详情", notes = "参数：id")
    public Object findNewsById(String id)  {
        return success(yenlienService.findNewsById(id));
    }
    @GetMapping(value = "/delNewsById")
    @ApiOperation(value = "根据ID删除新闻资讯", notes = "参数：id")
    public Object delNewsById(String id)  {
        yenlienService.delNewsById(id);
        return success("success");
    }
    @GetMapping(value = "/setNewsState")
    @ApiOperation(value = "根据ID修改新闻资讯状态, ", notes = "参数：id, state(1=待发布 2=已发布)")
    public Object setNewsState(String id, String state)  {
        return success(yenlienService.setNewsState(id, state));
    }





    @GetMapping(value = "/findYenlien")
    @ApiOperation(value = "获取关于我们信息", notes = "")
    public Object findYenlien()  {
        return success(yenlienService.findYenlien());
    }

    @GetMapping(value = "/findProdType")
    @ApiOperation(value = "获取产品服务类型")
    public Object findProdType()  {
        return success(yenlienService.findProdType());
    }


    @GetMapping(value = "/findBannerType")
    @ApiOperation(value = "获取Banner可选类型")
    public Object findProdType(String flag)  {
        return success(Arrays.asList("首页", "产品服务", "解决方案", "项目案例", "最新动态", "关于我们"));
    }






























}
